{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>优惠券添加</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券分类名称</label>
            <div class="layui-input-4">
                <input type="text" maxlength="200" name="title" value="" lay-verify="required" placeholder="请输入优惠券分类名称" class="layui-input">
            </div>
        </div>
       
		<div class="layui-form-item">
            <label class="layui-form-label">优惠券状态</label>
           <div class="layui-input-4">
            <input type="radio" name="status" value="0" title="正常" checked>
			  <input type="radio" name="status" value="1" title="下架" >
           </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="submit" lay-submit="" lay-filter="sys">{:lang('submit')}</button>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script>
    layui.use(['form', 'layer','upload'], function () {
        var form = layui.form,layer = layui.layer,upload = layui.upload,$ = layui.jquery;
		form.verify({
            title: function(value){  
						if(value == ''){  
							return '请输入优惠券分类名称!';  
						}  
					},
							
				});
		//提交监听
        form.on('submit(sys)', function (data) {
			$("#submit").attr({ disabled: "disabled" });
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("{:url('cateAdd')}",data.field,function(res){
                layer.close(loading);
                if(res.errorCode == 8888){
                    layer.msg(res.msg,{icon: 1, time: 1000},function(){
                        location.href = '{:url("cate")}';
                    });
                }else{
					$("#submit").removeAttr("disabled");
                    layer.msg(res.msg,{icon: 2, time: 1000});
                }
            });
        })
    })
	

</script>


</body>
</html>